﻿#region Copyright
// Copyright (c) 2011-2012 RaisingForce Team (Alikin Sergey)
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#endregion

using System;
using System.Diagnostics.Contracts;
using RaisingForce.Raise.Presentation.Rules;

namespace RaisingForce.Raise.Presentation.ViewModel.Specialized
{
    public abstract class SettingBoxBaseViewModel :
        SettingViewModel
    {
        #region Constructors

        protected SettingBoxBaseViewModel(string errorText, string errorEmptyText)
            : base()
        {
            if (!ValidationRuleRules.ErrorTextIsValid(errorText))
            {
                throw new ArgumentNullException("errorText");
            }
            if (!ValidationRuleRules.ErrorTextIsValid(errorEmptyText))
            {
                throw new ArgumentNullException("errorEmptyText");
            }
            Contract.EndContractBlock();
            this.errorText = errorText;
            this.errorEmptyText = errorEmptyText;
        }

        #endregion

        #region Protected Declarations

        private readonly string errorText;

        protected string ErrorText
        {
            get
            {
                Contract.Ensures(ValidationRuleRules.ErrorTextIsValid(Contract.Result<string>()));
                return this.errorText;
            }
        }

        private readonly string errorEmptyText;

        protected string ErrorEmptyText
        {
            get
            {
                Contract.Ensures(ValidationRuleRules.ErrorTextIsValid(Contract.Result<string>()));
                return this.errorEmptyText;
            }
        }

        #endregion

        #region ViewModel Properties

        private int labelMinWidth;

        public int LabelMinWidth
        {
            get { return this.labelMinWidth; }
            set
            {
                this.SetProperty(
                    ref this.labelMinWidth,
                    value,
                    "LabelMinWidth");
            }
        }

        #endregion
    }
}
